//------------------------------------------------------------------------------

#include <stdlib.h>
#include <string.h>

void reallocEx(char **buffer, int bufferSize, int toAdd) {
	if (*buffer == 0 || bufferSize == 0) {
		*buffer = (char *) calloc(toAdd, sizeof(char));
	} else {
		*buffer = (char *) realloc(*buffer,
				(bufferSize + toAdd) * sizeof(char));
	}
}
//------------------------------------------------------------------------------
int reallocExCpy(char **buffer, int bufferSize, char *toCpy) {
	int toAdd = strlen(toCpy);
	int newSize = bufferSize + toAdd;
	reallocEx(buffer, bufferSize, toAdd + 1);
	strcpy(&((*buffer)[bufferSize]), toCpy);

	return newSize;
}
//------------------------------------------------------------------------------
